import { Color, PerspectiveCamera, Scene, WebGLRenderer } from "three";
import { GLTFLoader, OrbitControls } from "three/examples/jsm/Addons.js";

export default class Y3Engine {
  constructor(options) {
    this.options = options;
    this.init();
    this.animate();
  }

  init() {
    this.initScene();
    this.initCamera();
    this.initRenderer();
    this.initControls();
  }

  initRenderer() {
    this.renderer = new WebGLRenderer({ antialias: true });
    this.renderer.setSize(window.innerWidth, window.innerHeight);
    document.body.appendChild(this.renderer.domElement);
  }

  initCamera() {
    this.camera = new PerspectiveCamera(
      75,
      window.innerWidth / window.innerHeight,
      0.1,
      1000
    );
  }

  initScene() {
    this.scene = new Scene();
    this.scene.background = new Color(0x123456);
  }
  initControls() {
    const controls = new OrbitControls(this.camera, this.renderer.domElement);
  }

  animate = () => {
    requestAnimationFrame(this.animate);
    this.renderer.render(this.scene, this.camera);
  };
}

window.addEventListener("DOMContentLoaded", () => {
  const engine = new Y3Engine({});
});
